home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 3 / Your Choice Software Collection 3.iso / prgmming / gxldemo / g_test.cpp next >
C/C++ Source or Header  |  1994-09-24  |  60KB  |  2,235 lines

  1. // G_TEST.CPP
  2. //
  3. // Genesis Graphical Interface Application Library version 2
  4. // Copyright (c) '93 by Kevin C.W. Hise - All rights reserved.
  5. //
  6. // sample and test program.
  7.  
  8. #include "g_test.hpp"
  9.  
  10.  
  11. #if defined ( USE_META )
  12. extern unsigned _stklen = 14336U;
  13. #include <metaqery.hpp>
  14. #endif
  15.  
  16.  
  17.  
  18. // ================
  19. // code starts here
  20. // ================
  21.  
  22. int main( int argc, char **argv )
  23. {
  24.  
  25.     // allocate the GL2 kernel
  26.  
  27.     KERNEL * kernel  = new KERNEL( 16, 32 );
  28.  
  29.     // set the default system button size
  30.     kernel->system_button_height =
  31.         kernel->system_button_width = 24;
  32.  
  33.     kernel->color_table = colorTable;
  34.  
  35.  
  36.     // initialize the unknown mouse device to null
  37.  
  38.     MOUSE_DEVICE * mouse = NULL;
  39.  
  40.  
  41. #if defined ( USE_BGI )
  42.  
  43.     // setup the BGI display
  44.  
  45.     BGI_DISPLAY * display = new BGI_DISPLAY( "\\bc\\bgi", VGA, VGAHI );
  46.  
  47. // using super-vga drivers
  48. //    BGI_DISPLAY * display = new BGI_DISPLAY( "\\BC\\BGI", DETECT, SVGA640x480, "SVGA256" );
  49.  
  50.     if ( !display || display->is_installed == false )
  51.     {
  52.         int err = display ? display->error_code : 0;
  53.         cout << "BGI error: " << err << ' ' << grapherrormsg( err ) << "\n\n";
  54.         exit( 0 );
  55.     }
  56.  
  57.     san_font = display->AddFont( SANS_SERIF_FONT, 4 );
  58.     tri_font = display->AddFont( TRIPLEX_FONT, 4 );
  59.     scr_font = display->AddFont( TRIPLEX_SCR_FONT, 4 );
  60.  
  61. #elif defined ( USE_META )
  62.  
  63.     int card = -1, input;
  64.  
  65.     MetaQuery( card, input, argc, argv );
  66.  
  67.     METAWINDOW_DISPLAY * display = new METAWINDOW_DISPLAY( card );
  68.  
  69.     if ( !display || display->is_installed == false )
  70.     {
  71.         int err = display ? display->error_code : 0;
  72.         cout << "METAGRAPHICS error: " << err << "\n\n";
  73.         exit(0);
  74.     }
  75.  
  76.     scr_font = display->AddFont( "SYSTEM96.FNT" );
  77.     tri_font = display->AddFont( "SYSTEM64.FNT" );
  78.     san_font = display->AddFont( "SYSTEM72.FNT" );
  79.  
  80. #endif
  81.  
  82.     display->explode_effect = 10;
  83.  
  84.     // parse the command line (if there is one) to determine the pointer device desired
  85.  
  86.     *kernel + display;                      // display device
  87.  
  88.     if ( argc == 1 )
  89. #if defined ( USE_BGI )
  90.         mouse = new MS_MOUSE;
  91. #elif defined ( USE_META )
  92.         mouse = new METAGRAPHICS_MOUSE(input);
  93. #endif
  94.     else
  95.         for( int argn = 1; argn < argc; argn++ )
  96.         {
  97.             strupr( argv[ argn ] );
  98.  
  99.             if ( !strncmp( argv[ argn ], "MOUSE=", 6 ) && !mouse )
  100.             {
  101.                 if ( !strncmp( argv[ argn ]+6, "ELO", 3 ) )
  102.                     *kernel + new ELODEV( 0x65, 2 );
  103.             }
  104.         }
  105.  
  106.     // tell the display there's a mouse ( if mouse is NULL, there is no effect )
  107.  
  108.     display->mouse = mouse;
  109.  
  110.  
  111.     // add some devices to the kernel
  112.  
  113.     *kernel + mouse                         // mouse ( a NULL is ignored )
  114.             + new KEYBOARD( 0x011B )        // BIOS keyboard with Esc as hot-key
  115.             + ( event_timer = new TIMER )   // programmable event timer
  116.             + new MENU_MANAGER              // POS demo menu manager
  117.             + new TICKET_MANAGER;           // ticket manager
  118.  
  119.     // add the screen saver timer and it's window
  120.  
  121.     *kernel + new SCREEN_SAVER( 60, new STARFIELD( 50, 25 ) );
  122.  
  123.     // add the desktop and main window
  124.  
  125.     // create a desktop ( must add after the display )
  126.  
  127.     desktop = new WINDOW;
  128.  
  129.     desktop->flags = WOF_DESKTOP | WOF_BACKGROUND | WOF_CAN_DELETE;
  130.     desktop->color = kernel->GetScheme( SID_CANVAS );
  131.  
  132.     *kernel + desktop
  133.             + new MAIN_WINDOW;
  134.  
  135.     // process events and return a code
  136.  
  137.     int code = kernel->Exec();
  138.  
  139.     // remove all windows, shut-down the system, and return to DOS
  140.  
  141.     delete kernel;
  142.  
  143.     // display a copyright / sign-off message
  144.  
  145.     cout << "\
  146. The GXL Graphical Interface Library Demo (v2.1).\n\
  147. Copyright (c) 1992-1995 Hise Development - All rights reserved.\n\n\
  148. This demonstration, including drivers, may be copied or distributed freely.\n\n\
  149. For inquiries contact:\n\
  150.   GeNT Computer Services\n\
  151.   114-C Gemstone\n\
  152.   Ridgecrest, CA 93555\n\
  153.   Voice: (619) 384-2847\n\
  154.   Fax:   (619) 371-1054\n\n\
  155. Complete GXL package includes class libraries and C++ source with examples\n\
  156. (over 600KB) and 120+ page manual.  Supports Borland(tm) 3.1 or later.\n\
  157. \n\n\
  158. DISPLAY_DEVICE Graphics Primitives and fonts:\n";
  159.  
  160. #if defined ( USE_BGI )
  161.     cout << "  > Borland Graphics Interface (BGI) version 3.1\n  > Copyright (c) Borland International.\n\nAlso supports Metagraphics MetaWINDOW 4.x";
  162. #elif defined ( USE_META )
  163.     cout << "  > Metagraphics MetaWINDOW version 4.3 (DOS real-mode)\n  > Copyright (c) Metagraphics Software Corporation.\n  > (MetaWINDOW must be purchased separately.)\n\nAlso supports Borland BGI 3.1";
  164. #endif
  165.  
  166.     // return a child-process code
  167.  
  168.     return code;
  169.  
  170. }
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179. // ==========================
  180. // MAIN_WINDOW implementation
  181.  
  182.  
  183. MAIN_WINDOW::MAIN_WINDOW( void ) : WINDOW()
  184. {
  185.     // set the windows coords on the display
  186.  
  187.     object_area = CenterRect( display->area, 240, 415 );
  188.  
  189.     // init the color scheme
  190.  
  191.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  192.  
  193.     // add a border, title bar and help bar
  194.  
  195.     *this + new THREE_D_BORDER( SID_BORDER )
  196.           + new TITLE_BAR( SID_TITLE_BAR, "GXL DEMO" )
  197.           + ( help_bar = new HELP_BAR( SID_MAIN_WINDOW, help_context[0] ) );
  198.  
  199.     // now add the menu selection buttons
  200.  
  201.     *this + new LABEL( 115, 8, SID_TEXT, "Sample Objects", 0, 0, WOF_TEXT_CJ );
  202.  
  203.     gRECT r = { 5, 25, -70, -70 };
  204.     *this + new OPTION( r, SID_BUTTON, "Exit", 0, ico_exit, C_EXIT, WOF_P_BUTTON | WOF_SEND_QUEUE );
  205.  
  206.     MoveRectX( r, 75 );
  207.     *this + new OPTION( r, SID_BUTTON, "Windows", 0, ico_windows, C_WINDOW, WOF_P_BUTTON | WOF_SEND_QUEUE );
  208.  
  209.     MoveRectX( r, 75 );
  210.     *this + new OPTION( r, SID_BUTTON, "Buttons", 0, ico_buttons, C_BUTTON_OBJECTS, WOF_P_BUTTON | WOF_SEND_QUEUE );
  211.  
  212.     MoveRectY( r, 75 );  r.left = 5;
  213.     *this + new OPTION( r, SID_BUTTON, "Desktop\rColors", 0, ico_paint, C_SET_DESKTOP, WOF_P_BUTTON | WOF_SEND_QUEUE );
  214.  
  215.     MoveRectX( r, 75 );
  216.     *this + new OPTION( r, SID_BUTTON, "Text", 0, ico_text, C_TEXT_OBJECTS, WOF_P_BUTTON | WOF_SEND_QUEUE );
  217.  
  218.     MoveRectX( r, 75 );
  219.     *this + new OPTION( r, SID_BUTTON, "Clocks", 0, ico_clock, C_CLOCK, WOF_P_BUTTON | WOF_SEND_QUEUE );
  220.  
  221.     MoveRectY( r, 75  );  r.left = 5;
  222.     *this + new OPTION( r, SID_BUTTON, "List\rBox", 0, NULL, C_LIST, WOF_P_BUTTON | WOF_SEND_QUEUE );
  223.  
  224.     MoveRectX( r, 75 );
  225.     *this + new OPTION( r, SID_BUTTON, "Input", 0, NULL, C_INPUT, WOF_P_BUTTON | WOF_SEND_QUEUE );
  226.  
  227.     MoveRectX( r, 75 );
  228.     *this + new OPTION( r, SID_BUTTON, "Pick\rFile", 0, NULL, C_PICK_FILE, WOF_P_BUTTON | WOF_SEND_QUEUE );
  229.  
  230.     *this + new LABEL( 115, 255, SID_TEXT, "Sample Applications", 0, 0, WOF_TEXT_CJ );
  231.  
  232.     InitRect( r, 5, 275, -70, -70 );
  233.     *this + new OPTION( r, SID_BUTTON, "Point\rOf Sale", 0, NULL, C_POS, WOF_P_BUTTON | WOF_SEND_QUEUE );
  234.  
  235. }
  236.  
  237.  
  238. // handle events for the main window
  239.  
  240. EVENT_STATUS MAIN_WINDOW::Event( EVENT & event )
  241. {
  242.     EVENT_STATUS ret = ES_OK;   // default return value
  243.  
  244.     switch( event.type )
  245.     {
  246.     case EV_OPTION:     // a menu option was selected
  247.         if ( event.data.mouse_t.button )
  248.             switch( event.code )    // find out which one was selected ( in 'code' )
  249.             {
  250.             case C_EXIT:            // set the flag in the kernel object to true
  251.                 kernel->halt = true;
  252.                 break;
  253.  
  254.             case C_WINDOW:          // add the sample window to the screen
  255.                 kernel->AddWindow( (new SAMPLE_WINDOW() ), event.area );
  256.                 break;
  257.  
  258.             case C_SET_DESKTOP:    // add the wallpaper color/pattern modifier
  259.                 kernel->AddWindow( (new SET_DESKTOP()) ,event.area );
  260.                 break;
  261.  
  262.             case C_TEXT_OBJECTS:    // add the sample text objects window
  263.                 kernel->AddWindow( (new TEXT_WINDOW()), event.area );
  264.                 break;
  265.  
  266.             case C_BUTTON_OBJECTS:  // add the sample button objects
  267.                 kernel->AddWindow( (new BUTTON_WINDOW()), event.area );
  268.                 break;
  269.  
  270.             case C_CLOCK:           // add the analog and digital clocks window
  271.                 kernel->AddWindow( (new CLOCK_WINDOW()), event.area );
  272.                 break;
  273.  
  274.             case C_LIST:
  275.                 kernel->AddWindow( (new LIST_WINDOW()), event.area );
  276.                 break;
  277.  
  278.             case C_INPUT:
  279.                 kernel->AddWindow( (new INPUT_WINDOW()), event.area );
  280.                 break;
  281.  
  282.             case C_PICK_FILE:
  283.                 kernel->AddWindow( (new PICK_WINDOW()), event.area );
  284.                 break;
  285.  
  286.             case C_POS:
  287.  
  288.                 // tell the window manager to close all windows
  289.  
  290.                 AddUIEvent( EV_CLOSE_ALL );
  291.  
  292.                 // then add the main POS window - use an event so window
  293.                 // is added after all other windows are closed
  294.  
  295.                 EVENT ev;
  296.  
  297.                 ev.type         = EV_ADD_WINDOW;
  298.                 ev.target_id    = OI_KERNEL;
  299.                 ev.area         = event.area;
  300.                 ev.ptr.window_t = new POS_MENU_WINDOW();
  301.                 AddUIEvent( ev );
  302.  
  303.                 ev.ptr.window_t = new POS_TICKET_WINDOW();
  304.                 AddUIEvent( ev );
  305.                 break;
  306.             }
  307.         break;
  308.  
  309.     default:            // otherwise, send the event to the base class 'window'
  310.         ret = WINDOW::Event( event );
  311.  
  312.     }
  313.  
  314.     return ret;
  315.  
  316. }
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324. // ====================
  325. // a menu OPTION button
  326.  
  327.  
  328. OPTION::OPTION
  329. (
  330.     gRECT &              r,
  331.     SCHEME_ID           c,
  332.     const char *        t,
  333.     int                 fh,
  334.     EVENT_CODE          opt,
  335.     bit_flag_t          bf
  336.  
  337. ) : COMBO_BUTTON( r, c, t, fh, bf, EV_OPTION, opt )
  338. {
  339.     option = opt;
  340. }
  341.  
  342.  
  343.  
  344. OPTION::OPTION
  345. (
  346.     gRECT &              r,
  347.     SCHEME_ID           c,
  348.     const pixel_array * pa,
  349.     EVENT_CODE          opt,
  350.     bit_flag_t          bf
  351.  
  352. ) : COMBO_BUTTON( r, c, pa, bf, EV_OPTION, opt )
  353. {
  354.     option = opt;
  355. }
  356.  
  357.  
  358. OPTION::OPTION
  359. (
  360.     gRECT &              r,
  361.     SCHEME_ID           c,
  362.     const char *        t,
  363.     int                 fh,
  364.     const pixel_array * pa,
  365.     EVENT_CODE          opt,
  366.     bit_flag_t          bf
  367.  
  368. ) : COMBO_BUTTON( r, c, t, fh, pa, bf, EV_OPTION, opt )
  369. {
  370.     option = opt;
  371. }
  372.  
  373.  
  374.  
  375. EVENT_STATUS OPTION::Event( EVENT & event )
  376. {
  377.     EVENT_STATUS ret = ES_OK;
  378.  
  379.     switch( event.type )
  380.     {
  381.     case EV_CURRENT:
  382.         help_bar->ChangeText( help_context[ option ] );
  383.         goto CONTINUE;
  384.  
  385.     case EV_NON_CURRENT:
  386.         help_bar->ChangeText( help_context[ 0 ] );
  387.         goto CONTINUE;
  388.  
  389.     CONTINUE:
  390.  
  391.     default:
  392.         ret = COMBO_BUTTON::Event( event );
  393.     }
  394.  
  395.     return ret;
  396.  
  397. }
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406. // ====================================
  407. // implementation for the sample window
  408.  
  409.  
  410. SAMPLE_WINDOW::SAMPLE_WINDOW( void ) : WINDOW()
  411. {
  412.     object_area = CenterRect( display->area, 200, 150 );
  413.  
  414.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  415.  
  416.     gRECT r = { 60, 70, -70, -30 };
  417.  
  418.     *this + new THREE_D_BORDER( SID_BORDER )
  419.           + new TITLE_BAR( SID_TITLE_BAR, "Blank Window" )
  420.           + new OPTION( r, SID_BUTTON, "Close", 0, ico_ok, C_CLOSE )
  421.           + new LABEL( 95, 30, SID_TEXT, "Sample Dialog Text", 0, 0, WOF_TEXT_CJ );
  422.  
  423. // *** programmable TIMER bug-busting, 1/94
  424. //    EVENT ev;
  425. //    ev.type = EV_TIMEOUT;
  426. //    thandle1 = event_timer->Add( TT_INTERVAL, this, ev, BIOS_TICKS_PER_SECOND * 25, 1, false );
  427.  
  428. //    ev.type = EV_TIMER;
  429. //    thandle2 = event_timer->Add( TT_SECOND, this, ev, 0, 20, false );
  430.  
  431. }
  432.  
  433.  
  434.  
  435. EVENT_STATUS SAMPLE_WINDOW::Event( EVENT & event )
  436. {
  437.     EVENT_STATUS ret = ES_OK;
  438.  
  439.     switch( event.type )
  440.     {
  441. //    case EV_TIMER:
  442. //        display->DrawLine( window, client_area.left, client_area.top, client_area.right, client_area.bottom, ((event.data.int_t.z%2) ? black : white) );
  443. //        break;
  444.  
  445.     case EV_OPTION:
  446. //        event_timer->Remove( thandle1 );
  447. //
  448. //    case EV_TIMEOUT:
  449. //        event_timer->Remove( thandle2 );
  450.         kernel->RemoveWindow( this );
  451. //        break;
  452.  
  453.     default:
  454.         ret = WINDOW::Event( event );
  455.     }
  456.  
  457.     return ret;
  458.  
  459. }
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468. // ===========================================
  469. // implementation for the sample button window
  470.  
  471.  
  472. BUTTON_WINDOW::BUTTON_WINDOW( void ) : WINDOW()
  473. {
  474.     object_area = CenterRect( display->area, 450, 300 );
  475.  
  476.     color = kernel->GetScheme( SID_BUTTON );
  477.  
  478.     strcpy( x_buf, "X = 0" );
  479.     strcpy( y_buf, "Y = 0" );
  480.  
  481.     *this + new THREE_D_BORDER( SID_BORDER )
  482.           + new TITLE_BAR( SID_TITLE_BAR, "Button object types" )
  483.           + new SCROLL_BAR( SID_SCROLL, SID_BUTTON, 0, 20, 10, SB_V_EDGE | SB_USE_CORNER )
  484.           + new SCROLL_BAR( SID_SCROLL, SID_BUTTON, 0, 20, 10, SB_H_EDGE )
  485.           + ( x_text = new LABEL( 10, 170, SID_BLACK_TEXT, x_buf, 0 ) )
  486.           + ( y_text = new LABEL( 10, 190, SID_BLACK_TEXT, y_buf, 0 ) )
  487.     ;
  488.  
  489.     x_scroll =
  490.         y_scroll = 0;
  491.  
  492.     gRECT r = { 5, 5, -70, -50 };
  493.     *this + new COMBO_BUTTON( r, SID_BUTTON, "Text\rOnly", 0 );
  494.  
  495.     MoveRectY( r, 55 );
  496.     *this + new COMBO_BUTTON( r, SID_BUTTON, "Icon\r& Text", 0, ico_ok, WOF_P_BUTTON );
  497.  
  498.     MoveRectY( r, 55 );
  499.     *this + new COMBO_BUTTON( r, SID_BUTTON, ico_ok );
  500.  
  501.  
  502.     r.left = 85;  r.top = 5;  r.right = -55;  r.bottom = -55;
  503.     *this + new ROUND_BUTTON( r, SID_BUTTON, "Round", 0 );
  504.  
  505.     MoveRectY( r, 60 );
  506.     *this + new ARROW_BUTTON( r, SID_BUTTON, ABD_LEFT, "Left", 0 );
  507.  
  508.     MoveRectY( r, 60 ); gRECT b = r;  b.left += 5;  b.right += 10;
  509.     *this + new ROUND_BUTTON( b, SID_BUTTON, "Oval", 0 );
  510.  
  511.     MoveRectX( r, 60 );  r.top = 5;
  512.     *this + new ARROW_BUTTON( r, SID_BUTTON, ABD_UP, "Up", 0 );
  513.  
  514.     MoveRectY( r, 60 );
  515.     *this + new STOP_BUTTON( r, SID_W_RED, "Stop", 0 );
  516.  
  517.     MoveRectY( r, 60 );
  518.     *this + new ARROW_BUTTON( r, SID_BUTTON, ABD_DOWN, "Down", 0 );
  519.  
  520.     MoveRectX( r, 60 );  r.top = 5;  b = r;  b.top += 5;  b.bottom += 10;
  521.     *this + new ROUND_BUTTON( b, SID_BUTTON, "Oval", 0 );
  522.  
  523.     MoveRectY( r, 60 );
  524.     *this + new ARROW_BUTTON( r, SID_BUTTON, ABD_RIGHT, "Right", 0 );
  525.  
  526.     MoveRectY( r, 60 );
  527.     *this + new ROUND_BUTTON( r, SID_BUTTON, "Round", 0 );
  528.  
  529.     MoveRectX( r, 60 ); r.top = 5; b = r;  b.bottom += 10;
  530.     *this + new TRIANGLE_BUTTON( b, SID_BUTTON, ABD_UP, "Up", 0 );
  531.  
  532.     MoveRectY( r, 60 ); b = r;  b.bottom += 10;
  533.     *this + new TRIANGLE_BUTTON( b, SID_BUTTON, ABD_DOWN, "Down", 0 );
  534.  
  535.     MoveRectX( r, 60 ); r.top = 5; b = r;  b.right += 10;
  536.     *this + new TRIANGLE_BUTTON( b, SID_BUTTON, ABD_LEFT, "Left", 0 );
  537.  
  538.     MoveRectY( r, 60 ); b = r;  b.right += 10;
  539.     *this + new TRIANGLE_BUTTON( b, SID_BUTTON, ABD_RIGHT, "Right", 0 );
  540.  
  541.  
  542.     InitRect( r, 110, 195, -70, -30 );
  543.     *this + new OPTION( r, SID_BUTTON, "Close", 0, ico_ok, C_CLOSE );
  544.  
  545. }
  546.  
  547.  
  548.  
  549.  
  550. EVENT_STATUS BUTTON_WINDOW::Event( EVENT & event )
  551. {
  552.     EVENT_STATUS ret = ES_OK;
  553.  
  554.     switch( event.type )
  555.     {
  556.     case EV_OPTION:
  557.         kernel->RemoveWindow( this );
  558.         break;
  559.  
  560.     case EV_VSCROLL:
  561.         y_scroll += event.code;
  562.         sprintf( y_buf, "Y = %d", y_scroll );
  563.         y_text->ChangeData( y_buf );
  564.         break;
  565.  
  566.     case EV_HSCROLL:
  567.         x_scroll += event.code;
  568.         sprintf( x_buf, "X = %d", x_scroll );
  569.         x_text->ChangeData( x_buf );
  570.         break;
  571.  
  572.     default:
  573.         ret = WINDOW::Event( event );
  574.     }
  575.  
  576.     return ret;
  577.  
  578. }
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587. // =================================
  588. // the desktop editor implementation
  589.  
  590.  
  591. SET_DESKTOP::SET_DESKTOP( void ) : WINDOW()
  592. {
  593.     object_area = CenterRect( display->area, 415, 250 );
  594.  
  595.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  596.  
  597.     *this + new THREE_D_BORDER( SID_BORDER )
  598.           + new TITLE_BAR( SID_TITLE_BAR, "Change Desktop Colors" );
  599.  
  600.     gRECT r = { 10, 0, -175, -30 };
  601.     *this + new LABEL( r, SID_BLACK_TEXT, "Colors" );
  602.  
  603.     r.left = 220;
  604.     *this + new LABEL( r, SID_BLACK_TEXT, "Patterns" );
  605.  
  606.     int bsize = 32;
  607.  
  608.     InitRect( r, 10, 30, -bsize, -bsize );
  609.  
  610.     for (int n = 0; n < 16; n++ )
  611.     {
  612.         if ( n && !(n % (200/(bsize+2))) )
  613.         {
  614.             r.left = 10;
  615.             MoveRectY( r, bsize + 2 );
  616.         }
  617.         *this + new COLOR_OPTION( r, n, FILL_SOLID, n );
  618.         MoveRectX( r, bsize + 2 );
  619.     }
  620.  
  621.     int pmin, pmax;
  622.  
  623. #if defined ( USE_BGI )
  624.     bsize = 32;
  625.     pmin  = SOLID_FILL,
  626.     pmax  = CLOSE_DOT_FILL;
  627.  
  628. #elif defined ( USE_META )
  629.     bsize = 24;
  630.     pmin  = 1;
  631.     pmax  = 31;
  632.  
  633. #endif
  634.  
  635.     InitRect( r, 220, 30, -bsize, -bsize );
  636.  
  637.     for (n = pmin; n < pmax; n++ )
  638.     {
  639.         if ( (n-pmin) && !((n-pmin) % (200/(bsize+2))) )
  640.         {
  641.             r.left = 220;
  642.             MoveRectY( r, bsize + 2 );
  643.         }
  644.  
  645.         *this + new COLOR_OPTION( r, white, n, n+1000 );
  646.         MoveRectX( r, bsize + 2 );
  647.     }
  648.  
  649.     InitRect( r, 120, 180, -70, -30 );
  650.     *this + new OPTION( r, SID_BUTTON, "Ok", 0, ico_ok, C_OK );
  651.  
  652.     MoveRectX( r, 90 );
  653.     *this + new OPTION( r, SID_BUTTON, "Cancel", 0, ico_cancel, C_CANCEL );
  654.  
  655.     old_color   = desktop->color->fill;
  656.     old_pattern = desktop->color->pattern;
  657.  
  658. }
  659.  
  660.  
  661.  
  662.  
  663. EVENT_STATUS SET_DESKTOP::Event( EVENT & event )
  664. {
  665.     EVENT_STATUS ret = ES_OK;
  666.  
  667.     switch( event.type )
  668.     {
  669.     case EV_COLOR:
  670.         if ( event.code < 1000 )
  671.         {
  672.             desktop->color->fill = event.code;
  673.             kernel->RedrawArea( display->area, NULL, true, 1 );
  674.         }
  675.         else
  676.         {
  677.             desktop->color->pattern = event.code - 1000;
  678.             kernel->RedrawArea( display->area, NULL, true, 1 );
  679.         }
  680.         break;
  681.  
  682.     case EV_OPTION:
  683.         switch( event.code )
  684.         {
  685.         case C_CANCEL:
  686.             desktop->color->fill    = old_color;
  687.             desktop->color->pattern = old_pattern;
  688.  
  689.             kernel->RedrawArea( display->area, NULL, true, 1 );
  690.  
  691.         case C_OK:
  692.             kernel->RemoveWindow( this );
  693.             break;
  694.  
  695.         }
  696.         break;
  697.  
  698.     default:
  699.         ret = WINDOW::Event( event );
  700.     }
  701.  
  702.     return ret;
  703.  
  704. }
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714. // ==============================================
  715. // color and pattern swatch button implementation
  716.  
  717.  
  718. COLOR_OPTION::COLOR_OPTION
  719. (
  720.     gRECT &     r,   // area of button
  721.     int        c,   // color of swatch
  722.     int        p,   // pattern of swatch
  723.     EVENT_CODE opt  // option to return
  724.  
  725. ) : BUTTON( r, SID_BUTTON )
  726. {
  727.     col    = c;
  728.     pat    = p;
  729.     option = opt;
  730.  
  731. }
  732.  
  733.  
  734.  
  735. EVENT_STATUS COLOR_OPTION::Event( EVENT & event )
  736. {
  737.     EVENT_STATUS ret = ES_OK;
  738.  
  739.     switch( event.type )
  740.     {
  741.     case EV_INITIALIZE:
  742.         BUTTON::Event( event );
  743.         swatch_area = data_area - 2;
  744.         break;
  745.  
  746.     case EV_MOVE:
  747.         MoveRect( swatch_area, event.data.int_t.x, event.data.int_t.y );
  748.  
  749.     default:
  750.         ret = BUTTON::Event( event );
  751.     }
  752.  
  753.     return ret;
  754.  
  755. }
  756.  
  757.  
  758.  
  759. void COLOR_OPTION::Draw( void )
  760. {
  761.     BUTTON::Draw();
  762.  
  763.     display->SetFillStyle( pat, col );
  764.     display->DrawFilledRectangle( swatch_area );
  765.     display->DrawRectangle( swatch_area, black );
  766.  
  767. }
  768.  
  769.  
  770.  
  771. void COLOR_OPTION::Selected( boolean status )
  772. {
  773.     BUTTON::Selected( status );
  774.  
  775.     if ( status == false )
  776.     {
  777.         EVENT ev;
  778.  
  779.         ev.type      = EV_COLOR;
  780.         ev.code      = option;
  781.         ev.target_id = OI_KERNEL;
  782.         ev.source    = this;
  783.  
  784.         AddUIEvent( ev );
  785.     }
  786.  
  787. }
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797. // ==============================
  798. // the sample text objects window
  799.  
  800.  
  801. TEXT_WINDOW::TEXT_WINDOW( void ) : WINDOW()
  802. {
  803.     object_area = CenterRect( display->area, 400, 210 );
  804.  
  805.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  806.  
  807.     *this + new THREE_D_BORDER( SID_BORDER )
  808.           + new TITLE_BAR( SID_TITLE_BAR, "Text Objects" );
  809.  
  810.     *this + new LABEL( 195, 5,   SID_BLACK_TEXT,  "Left Justify",   tri_font, 0, WOF_TEXT_LJ  )
  811.           + new LABEL( 195, 30,  SID_BLACK_TEXT,  "Right Justify",  san_font, 0, WOF_TEXT_RJ )
  812.           + new LABEL( 195, 60,  SID_BLACK_TEXT,  "Center Justify", scr_font, 0, WOF_TEXT_CJ )
  813.           + new LABEL( 195, 110, SID_TEXT, "Blinking Text",  0, 0, WOF_TEXT_CJ | WOF_BLINK );
  814.  
  815.     gRECT r = { 160, 130, -70, -30 };
  816.     *this + new OPTION( r, SID_BUTTON, "Close", 0, ico_ok, C_CLOSE );
  817.  
  818. }
  819.  
  820.  
  821.  
  822.  
  823. EVENT_STATUS TEXT_WINDOW::Event( EVENT & event )
  824. {
  825.     EVENT_STATUS ret = ES_OK;
  826.  
  827.     switch( event.type )
  828.     {
  829.     case EV_OPTION:
  830.         if ( event.code == C_CLOSE )
  831.             kernel->RemoveWindow( this );
  832.         break;
  833.  
  834.     default:
  835.         ret = WINDOW::Event( event );
  836.     }
  837.  
  838.  
  839.     return ret;
  840.  
  841. }
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858. // ============================
  859. // clocks window implementation
  860.  
  861.  
  862.  
  863. CLOCK_WINDOW::CLOCK_WINDOW( void ) : WINDOW()
  864. {
  865.     object_area = CenterRect( display->area, 255, 300 );
  866.  
  867.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  868.  
  869.     *this + new THREE_D_BORDER( SID_BORDER )
  870.           + new TITLE_BAR( SID_TITLE_BAR, "Clocks" );
  871.  
  872.  
  873.     gRECT r = { 5, 5, -80, -90 };
  874.     *this + new CLOCK( r, SID_BUTTON, SID_CLOCK, 0 );
  875.  
  876.     MoveRectY( r, 95 ); r.right = -80;
  877.     *this + new CLOCK( r, SID_BUTTON, SID_CLOCK, 0 , CF_ANALOG | CF_SHOW_TIME | CF_PORTRAIT );
  878.  
  879.     MoveRectY( r, 95 ); r.bottom = -60;
  880.     *this + new CLOCK( r, SID_BUTTON, 0 );
  881.  
  882.     InitRect( r, 90, 5, -150, -60 );
  883.     *this + new CLOCK( r, SID_BUTTON, SID_CLOCK, 0, CF_ANALOG | CF_LANDSCAPE | CF_SHOW_TIME | CF_SHOW_SECONDS | CF_SHOW_DATE );
  884.  
  885.     MoveRectY( r, 65 );  r.bottom = -40;
  886.     *this + new CLOCK( r, SID_BUTTON, 0, CF_DIGITAL | CF_LANDSCAPE | CF_SHOW_DATE | CF_SHOW_TIME | CF_SHOW_SECONDS );
  887.  
  888.     MoveRectY( r, 45 );  r.right = -80; r.bottom = -30;
  889.     *this + new CLOCK( r, SID_BUTTON, 0, CF_DIGITAL | CF_SHOW_TIME | CF_AMPM | CF_PORTRAIT );
  890.  
  891.     MoveRectY( r, 35 ); r.bottom = -40;
  892.     *this + new CLOCK( r, SID_BUTTON, 0, CF_DIGITAL | CF_SHOW_DATE | CF_PORTRAIT );
  893.  
  894.  
  895.     InitRect( r, 130, 220, -70, -30 );
  896.     *this + new OPTION( r, SID_BUTTON, "Ok", 0, ico_ok, C_CLOSE );
  897.  
  898. }
  899.  
  900.  
  901.  
  902.  
  903.  
  904. EVENT_STATUS CLOCK_WINDOW::Event( EVENT & event )
  905. {
  906.  
  907.     EVENT_STATUS ret = ES_OK;
  908.  
  909.     switch( event.type )
  910.     {
  911.     case EV_OPTION:
  912.         kernel->RemoveWindow( this );
  913.         break;
  914.  
  915.     default:
  916.         ret = WINDOW::Event( event );
  917.     }
  918.  
  919.     return ret;
  920.  
  921. }
  922.  
  923.  
  924.  
  925.  
  926. // ==========================
  927. // List window implementation
  928.  
  929.  
  930. LIST_WINDOW::LIST_WINDOW( void ) : WINDOW()
  931. {
  932.     object_area = CenterRect( display->area, 200, 300 );
  933.  
  934.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  935.  
  936.     *this + new THREE_D_BORDER( SID_BORDER )
  937.           + new TITLE_BAR( SID_TITLE_BAR, "List Box" );
  938.  
  939.     gRECT r = { 10, 10, RectWidth(object_area) - 30, 198 };
  940.     VLIST * vlist = new VLIST( r, SID_VLIST );
  941.     *vlist + new SCROLL_BAR( SID_SCROLL, SID_BUTTON, 0, 0, 0, SB_V_EDGE );
  942.  
  943.     data = 0x1248;
  944.  
  945.     for( int n = 0; n < 16; n++ )
  946.     {
  947.         char buf[ 20 ];
  948.         sprintf( buf, "Item #%d", n+1 );
  949.  
  950.         int f = 1 << n;
  951.  
  952.         *vlist << new FLAG_ITEM( SID_ITEM, buf, 0, &data, false, f, ~f, WOF_FLAG_ITEM | WOF_ALLOCATE_TEXT );
  953.     }
  954.  
  955.     *this + vlist;
  956.  
  957.     InitRect( r, 60, 220, -70, -30 );
  958.     *this + new OPTION( r, SID_BUTTON, "Ok", 0, ico_ok, C_CLOSE );
  959. }
  960.  
  961.  
  962.  
  963. EVENT_STATUS LIST_WINDOW::Event( EVENT & event )
  964. {
  965.  
  966.     EVENT_STATUS ret = ES_OK;
  967.  
  968.     switch( event.type )
  969.     {
  970.     case EV_OPTION:
  971.         kernel->RemoveWindow( this );
  972.         break;
  973.  
  974.     default:
  975.         ret = WINDOW::Event( event );
  976.     }
  977.  
  978.     return ret;
  979.  
  980. }
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990. // ===================
  991. // input fields window
  992.  
  993.  
  994. INPUT_WINDOW::INPUT_WINDOW( void ) : WINDOW()
  995. {
  996.     object_area = CenterRect( display->area, 300, 295 );
  997.  
  998.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  999.  
  1000.     *this + new THREE_D_BORDER( SID_BORDER )
  1001.           + new TITLE_BAR( SID_TITLE_BAR, "Input Fields" );
  1002.  
  1003.     gRECT r;
  1004.  
  1005.     strcpy( string_field_1, "GXL v2.1 DEMO" );
  1006.     strcpy( string_field_2, "Touch Screen GUI Lib!" );
  1007.  
  1008.     int_data    = 0;
  1009.     long_data   = 0;
  1010.     double_data = 0.0;
  1011.  
  1012.     *this + new LABEL( 20, 10, SID_TEXT, "Program Name:", 0 )
  1013.           + new FIELD( 20, 25, SID_TEXT_FIELD, string_field_1, 0, 30, 30 )
  1014.  
  1015.           + new LABEL( 20, 45, SID_TEXT, "Cost:", 0 )
  1016.           + new FIELD( 20, 60, SID_TEXT_FIELD, string_field_2, 0, 30, 30 )
  1017.  
  1018.           + new LABEL( 20, 80, SID_TEXT, "Integer:", 0 )
  1019.           + new FIELD( 20, 95, SID_TEXT_FIELD, &int_data, "9999", 0 )
  1020.  
  1021.           + new LABEL( 20, 115, SID_TEXT, "Long:", 0 )
  1022.           + new FIELD( 20, 130, SID_TEXT_FIELD, &long_data, "99999999", 0 )
  1023.  
  1024.           + new LABEL( 20, 150, SID_TEXT, "Double (fixed decimal point):", 0 )
  1025.           + new FIELD( 20, 165, SID_TEXT_FIELD, &double_data, "9999999.9999", 0 )
  1026.  
  1027.           + new LABEL( 20, 185, SID_TEXT, "Double (floating decimal point):", 0 )
  1028.           + new FIELD( 20, 200, SID_TEXT_FIELD, &double_data, "999999999999", 0 );
  1029.  
  1030.     InitRect( r, 200, 220, -70, -30 );
  1031.     *this + new OPTION( r, SID_BUTTON, "Ok", 0, ico_ok, C_CLOSE );
  1032. }
  1033.  
  1034.  
  1035.  
  1036. EVENT_STATUS INPUT_WINDOW::Event( EVENT & event )
  1037. {
  1038.  
  1039.     EVENT_STATUS ret = ES_OK;
  1040.  
  1041.     switch( event.type )
  1042.     {
  1043.     case EV_OPTION:
  1044.         kernel->RemoveWindow( this );
  1045.         break;
  1046.  
  1047.     default:
  1048.         ret = WINDOW::Event( event );
  1049.     }
  1050.  
  1051.     return ret;
  1052.  
  1053. }
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061. PICK_WINDOW::PICK_WINDOW( void )
  1062. {
  1063.     object_area = CenterRect( display->area, 300, 300 );
  1064.  
  1065.     color = kernel->GetScheme( SID_MAIN_WINDOW );
  1066.  
  1067.     *this + new THREE_D_BORDER( SID_BORDER )
  1068.           + new TITLE_BAR( SID_TITLE_BAR, "Pick File" );
  1069.  
  1070.     gRECT r = { 10, 10, 0, 0 };
  1071.  
  1072.     *this + new PICK_FILE( r, "", SID_MAIN_WINDOW, WOF_PICK_FILE | WOF_3D_BORDER,
  1073.                                   SID_TEXT,        WOF_TEXT_LJ,
  1074.                                   SID_TEXT_FIELD,  WOF_FIELD,
  1075.                                   SID_VLIST,       WOF_VLIST,
  1076.                                   SID_SCROLL,      WOF_SCROLL_BAR,
  1077.                                   SID_BUTTON,
  1078.                                   SID_ITEM,
  1079.                                   0, 16 );
  1080.  
  1081.     object_area = CenterRect( display->area, r.right + 20, r.bottom + 100 );
  1082.  
  1083.     InitRect( r, 10, r.bottom + 20, -70, -30 );
  1084.     *this + new OPTION( r, SID_BUTTON, "Ok", 0, ico_ok, C_CLOSE );
  1085. }
  1086.  
  1087.  
  1088. EVENT_STATUS PICK_WINDOW::Event( EVENT & event )
  1089. {
  1090.     EVENT_STATUS ret = ES_OK;
  1091.  
  1092.     switch( event.type )
  1093.     {
  1094.     case EV_FILE_SELECT:
  1095.         if ( event.code < 2 )
  1096.             break;
  1097.  
  1098.     case EV_OPTION:
  1099.         kernel->RemoveWindow( this );
  1100.         break;
  1101.  
  1102.     default:
  1103.         ret = WINDOW::Event( event );
  1104.     }
  1105.  
  1106.     return ret;
  1107.  
  1108. }
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114. // ===========================
  1115. // Point-Of-Sale Demonstration
  1116. // ===========================
  1117.  
  1118.  
  1119. // define some clock settings and other bit-flag defaults
  1120.  
  1121. const bit_flag_t
  1122.  
  1123.     CSET_FLAGS = CF_ANALOG | CF_LANDSCAPE | CF_SHOW_TIME | CF_SHOW_SECONDS,
  1124.     COBJ_FLAGS = WOF_CAN_DELETE | WOF_IS_DRAWN,
  1125.     ITEM_FLAGS = WOF_L_BUTTON | WOF_SEND_QUEUE
  1126.  
  1127.     ;
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133. // -------------------------------
  1134. // the menu manager implementation
  1135.  
  1136. MENU_MANAGER::MENU_MANAGER( void )
  1137. {
  1138.     object_id      = OI_MENU_MANAGER;
  1139.     current_menu_n = 0;
  1140.     current_menu_p = NULL;
  1141.  
  1142. }
  1143.  
  1144.  
  1145. MENU_MANAGER::~MENU_MANAGER( )
  1146. {
  1147.  
  1148. }
  1149.  
  1150.  
  1151. EVENT_STATUS MENU_MANAGER::Event( EVENT & event )
  1152. {
  1153.     EVENT_STATUS ret = ES_OK;
  1154.  
  1155.     switch( event.type )
  1156.     {
  1157.     case EV_SELECT_MENU:
  1158.         if ( event.code != current_menu_n )
  1159.         {
  1160.             POS_MENU * new_menu = new POS_MENU;
  1161.  
  1162.             gRECT r;
  1163.  
  1164.             if ( new_menu )
  1165.             {
  1166.                 InitRect( new_menu->object_area, 250, 68, 640, 480 );
  1167.  
  1168.                 switch( event.code )
  1169.                 {
  1170.                 case MI_MAIN_MENU:
  1171.                     new_menu->color = kernel->GetScheme( SID_POS_MAIN_MENU );
  1172.  
  1173.                     InitRect( r,   4, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_DOUBLE );
  1174.                     MoveRectY( r, 68 );
  1175.                     MoveRectY( r, 68 );
  1176.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_LARGE );
  1177.  
  1178.  
  1179.                     InitRect( r,  81, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_BURGER );
  1180.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_CLUCK_BURGER );
  1181.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_BLT );
  1182.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_HOT_DOG );
  1183.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_POLISH_DOG );
  1184.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_ROAST_BEEF );
  1185.  
  1186.                     InitRect( r, 158, 4, -72, -64 );
  1187.  
  1188.                     InitRect( r, 235, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_CHEESE );
  1189.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_LETTUCE );
  1190.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_TOMATO );
  1191.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_ONION  );
  1192.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_PICKLE );
  1193.  
  1194.                     InitRect( r, 312, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_MAYO );
  1195.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_MUSTARD );
  1196.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_KETCHUP );
  1197.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_RELISH );
  1198.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_1000_ISLAND );
  1199.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_BBQ_SAUCE );
  1200.                     break;
  1201.  
  1202.                 case MI_SIDES_MENU:
  1203.                     new_menu->color = kernel->GetScheme( SID_POS_SIDES_MENU );
  1204.  
  1205.                     InitRect( r,   4, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_FRIES );
  1206.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_ONION_RINGS );
  1207.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_ZUCCINI_STICKS );
  1208.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_BROCCOLI );
  1209.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_MUSHROOMS );
  1210.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_MOZZARELLA_STICKS );
  1211.  
  1212.                     InitRect( r,  81, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_RANCH_DRESSING );
  1213.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_BBQ_SAUCE );
  1214.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_SWEET_N_SOUR );
  1215.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_TARTAR_SAUCE );
  1216.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_1000_ISLAND );
  1217.  
  1218.                     InitRect( r, 158, 4, -72, -64 );
  1219.  
  1220.                     InitRect( r, 235, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_SMALL_CUP );
  1221.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_MEDIUM_CUP );
  1222.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_LARGE_CUP );
  1223.                     MoveRectY( r, 68 );
  1224.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_DIET );
  1225.  
  1226.                     InitRect( r, 312, 4, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_RC_COLA );
  1227.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_7_UP );
  1228.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_ROOT_BEER );
  1229.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_ICE_TEA );
  1230.                     MoveRectY( r, 68 );               *new_menu + new MENU_BUTTON( r, MI_LEMON_WEDGE );
  1231.                     break;
  1232.  
  1233.                 case MI_CASH_MENU:
  1234.                     new_menu->color = kernel->GetScheme( SID_POS_CASH_MENU );
  1235.  
  1236.                     *new_menu + new LABEL( 150, 10,  SID_TEXT, "Sub-Total:", 0, 0, WOF_TEXT_RJ )
  1237.                               + ( new_menu->sub_total_text = new LABEL( 212,  10, SID_TEXT, "", 0, 0, WOF_TEXT_RJ ))
  1238.  
  1239.                               + new LABEL( 150, 30,  SID_TEXT, "Tax:", 0, 0, WOF_TEXT_RJ )
  1240.                               + ( new_menu->tax_text = new LABEL( 212,  30, SID_TEXT, "", 0, 0, WOF_TEXT_RJ ))
  1241.  
  1242.                               + ( new_menu->order_type_text = new LABEL( 150, 50,  SID_TEXT, "", 0, 0, WOF_TEXT_RJ ))
  1243.                               + ( new_menu->order_cost_text = new LABEL( 212,  50, SID_TEXT, "", 0, 0, WOF_TEXT_RJ ))
  1244.  
  1245.                               + new LABEL( 150, 70,  SID_TEXT, "Total:", 0, 0, WOF_TEXT_RJ )
  1246.                               + ( new_menu->grand_total_text = new LABEL( 212,  70, SID_TEXT, "", 0, 0, WOF_TEXT_RJ ))
  1247.  
  1248.                               + new LABEL( 150, 100, SID_TEXT, "Tendered:", 0, 0, WOF_TEXT_RJ )
  1249.                               + ( new_menu->tendered_field = new FIELD( 220, 100, SID_TEXT_FIELD, &new_menu->tendered, "9999.99", 0, ((WOF_FIELD & ~WOF_JUSTIFY_LEFT) | WOF_JUSTIFY_RIGHT) ) );
  1250.  
  1251.                     InitRect( r,   4, 140, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_DINING   );
  1252.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_DELIVERY );
  1253.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_TAKE_OUT );
  1254.  
  1255.                     InitRect( r,  81, 140, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_7 );
  1256.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_4 );
  1257.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_1 );
  1258.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_0 );
  1259.  
  1260.                     InitRect( r, 158, 140, -72, -64 );  *new_menu + new MENU_BUTTON( r, MI_8 );
  1261.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_5 );
  1262.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_2 );
  1263.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_BACK_SPACE );
  1264.  
  1265.                     InitRect( r, 235, 4, -72, -64 );    *new_menu + new MENU_BUTTON( r, MI_1_DOLLAR );
  1266.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_10_DOLLAR );
  1267.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_9 );
  1268.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_6 );
  1269.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_3 );
  1270.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_CLEAR_ENTRY );
  1271.  
  1272.                     InitRect( r, 312, 4, -72, -64 );    *new_menu + new MENU_BUTTON( r, MI_5_DOLLAR );
  1273.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_20_DOLLAR );
  1274.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_CASH );
  1275.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_CHECK );
  1276.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_VISA );
  1277.                     MoveRectY( r, 68 );                 *new_menu + new MENU_BUTTON( r, MI_MASTER_CARD );
  1278.  
  1279.                     // get the latest sub total and sale type
  1280.  
  1281.                     event.type      = EV_GET_SUB_TOTAL;
  1282.                     event.target_id = OI_TICKET_MANAGER;
  1283.                     AddBGEvent( event );
  1284.  
  1285.                     break;
  1286.  
  1287.                 default:
  1288.                     delete new_menu;
  1289.                     new_menu = NULL;
  1290.                 }
  1291.             }
  1292.  
  1293.             if ( new_menu )
  1294.                 kernel->ReplaceWindow( current_menu_p, new_menu, event.area );
  1295.  
  1296.             current_menu_n = event.code;
  1297.             current_menu_p = new_menu;
  1298.         }
  1299.         break;
  1300.  
  1301.     case EV_SUB_TOTAL:
  1302.     case EV_KEYBOARD:
  1303.         if ( current_menu_p )
  1304.             current_menu_p->Event( event );
  1305.         break;
  1306.  
  1307.     default:
  1308.         ret = ES_NOT_USED;
  1309.  
  1310.     }
  1311.  
  1312.     return ret;
  1313.  
  1314. }
  1315.  
  1316.  
  1317. EVENT_STATUS MENU_MANAGER::Poll( void )
  1318. {
  1319.     return ES_OK;
  1320.  
  1321. }
  1322.  
  1323.  
  1324.  
  1325. // -------------------
  1326. // ticket item manager
  1327.  
  1328. TICKET_LIST * TICKET_MANAGER::ticket_list = NULL;
  1329.  
  1330.  
  1331. TICKET_MANAGER::TICKET_MANAGER( void )
  1332. {
  1333.     object_id = OI_TICKET_MANAGER;
  1334.  
  1335.     sub_total         = 0;
  1336.  
  1337.     current_sale_type = MI_DINING;
  1338.  
  1339. }
  1340.  
  1341. TICKET_MANAGER::~TICKET_MANAGER()
  1342. {
  1343.     if ( itemList.Begin() )
  1344.     {
  1345.         do
  1346.         {
  1347.             delete (*itemList);
  1348.  
  1349.         }
  1350.         while( itemList.Next() );
  1351.  
  1352.         itemList.Flush();
  1353.     }
  1354.  
  1355. }
  1356.  
  1357. EVENT_STATUS TICKET_MANAGER::Event( EVENT & event )
  1358. {
  1359.     EVENT_STATUS ret = ES_OK;
  1360.  
  1361.     TICKET_ITEM * new_item,
  1362.                 * item_p = NULL;
  1363.  
  1364.     int item_n;
  1365.  
  1366.     // syncronize the lists
  1367.  
  1368.     if ( ticket_list )
  1369.     {
  1370.         item_p = (TICKET_ITEM *) ticket_list->p_selected;
  1371.         item_n = ticket_list->n_selected;
  1372.  
  1373.         itemList.Goto( item_n );
  1374.     }
  1375.  
  1376.     long old_cost = item_p ? item_p->cost : 0;
  1377.  
  1378.     switch( event.type )
  1379.     {
  1380.     case EV_CLEAR_TICKET:
  1381.         if ( itemList.Begin() )
  1382.         {
  1383.             if ( ticket_list )
  1384.                 ticket_list->Clear();
  1385.  
  1386.             do
  1387.             {
  1388.                 delete (*itemList);
  1389.             }
  1390.             while( itemList.Next() );
  1391.  
  1392.             itemList.Flush();
  1393.  
  1394.             current_sale_type = MI_DINING;
  1395.  
  1396.             old_cost          = sub_total;  // set 'old_cost' so it will reset the sub-total amount
  1397.             item_p            = NULL;
  1398.         }
  1399.         break;
  1400.  
  1401.     case EV_EDIT_ITEM:
  1402.         switch( event.code )
  1403.         {
  1404.         case C_MORE:                                                    // increment the quantity
  1405.             if ( item_p )
  1406.             {
  1407.                 item_p->Quantity( item_p->quantity + 1 );
  1408.  
  1409.                 if ( ticket_list )
  1410.                     ticket_list->IsVisible( item_n, true );
  1411.             }
  1412.             break;
  1413.  
  1414.         case C_LESS:                                                    // decrement the quantity
  1415.             if ( item_p && item_p->quantity > 0 )
  1416.             {
  1417.                 item_p->Quantity( item_p->quantity - 1 );
  1418.  
  1419.                 if ( ticket_list )
  1420.                     ticket_list->IsVisible( item_n, true );
  1421.             }
  1422.             break;
  1423.  
  1424.         case C_NO:                                                      // toggle the "NO" text
  1425.             if ( item_p && item_p->type == IT_MODIFIER )
  1426.             {
  1427.                 item_p->Quantity( ((item_p->quantity > 0) ? 0 : 1) );
  1428.  
  1429.                 if ( ticket_list )
  1430.                     ticket_list->IsVisible( item_n, true );
  1431.             }
  1432.             break;
  1433.  
  1434.         case C_TRASH:                                                   // delete an modifier or food + modifier
  1435.             if ( item_p )
  1436.             {
  1437.                 ITEM_TYPE type = item_p->type;      // get a copy of the item type
  1438.  
  1439.                 itemList.Goto( item_n );            // move to the item index in the list
  1440.  
  1441.                 if ( (*itemList) == item_p )        // do they match ??
  1442.                 {
  1443.                     old_cost = item_p->cost;
  1444.  
  1445.                     if ( ticket_list )              // is there a ticket-list on the display ?
  1446.                         *ticket_list -= item_p;     // delete the item from the list
  1447.  
  1448.                     delete (*itemList);             // remove the item from the ticket-manager's list
  1449.                     itemList.Remove();
  1450.  
  1451.                     // if the item was a FOOD item, delete the trailing modifiers
  1452.  
  1453.                     if ( type == IT_FOOD && itemList.Index() <= (itemList.Count() - 1) )
  1454.                         while( (*itemList)->type != IT_FOOD && item_n < itemList.Count() )
  1455.                         {
  1456.                             old_cost += (*itemList)->cost;
  1457.  
  1458.                             if ( ticket_list )
  1459.                                 *ticket_list -= (*itemList);
  1460.  
  1461.                             delete (*itemList);
  1462.                             itemList.Remove();
  1463.                         }
  1464.                 }
  1465.  
  1466.                 item_p = NULL;      // set to NULL so cost calculation works
  1467.             }
  1468.             break;
  1469.         }
  1470.         break;
  1471.  
  1472.     case EV_SELECT_ITEM:
  1473.         switch( menu_list[ event.code ].type )
  1474.         {
  1475.         case IT_FOOD:
  1476.             if ( item_p && item_p->type == IT_SIZE )
  1477.             {
  1478.                 item_p->Item( (MENU_ITEMS) event.code );
  1479.  
  1480.                 if ( ticket_list )
  1481.                     ticket_list->IsVisible( item_n, true );
  1482.             }
  1483.             else if ( item_p && item_p->item_index == (MENU_ITEMS) event.code )
  1484.             {
  1485.                 item_p->Quantity( item_p->quantity + 1 );
  1486.  
  1487.                 if ( ticket_list )
  1488.                     ticket_list->IsVisible( item_n, true );
  1489.             }
  1490.             else
  1491.             {
  1492.                 new_item = new TICKET_ITEM( (MENU_ITEMS) event.code );
  1493.  
  1494.                 new_item->Quantity( 1 );
  1495.  
  1496.                 itemList.Add( new_item );
  1497.  
  1498.                 if ( ticket_list )
  1499.                     ticket_list->Add( new_item );
  1500.  
  1501.                 old_cost = 0;
  1502.                 item_p   = new_item;
  1503.             }
  1504.             break;
  1505.  
  1506.         case IT_MODIFIER:
  1507.             if ( item_p && item_p->type == IT_FOOD || item_p->type == IT_MODIFIER )
  1508.             {
  1509.                 if ( item_p->type == IT_MODIFIER && item_p->item_index == (MENU_ITEMS) event.code )
  1510.                 {
  1511.                     item_p->Quantity( item_p->quantity + 1 );
  1512.  
  1513.                     if ( ticket_list )
  1514.                         ticket_list->IsVisible( item_n, true );
  1515.                 }
  1516.                 else
  1517.                 {
  1518.                     new_item = new TICKET_ITEM( (MENU_ITEMS) event.code );
  1519.                     new_item->Quantity( 1 );
  1520.  
  1521.                     itemList.PostInsert( new_item );
  1522.  
  1523.                     if ( ticket_list )
  1524.                         ticket_list->Insert( new_item );
  1525.  
  1526.                     old_cost = 0;
  1527.                     item_p   = new_item;
  1528.                 }
  1529.             }
  1530.             break;
  1531.  
  1532.         case IT_SIZE:
  1533.             if ( item_p == NULL || item_p->type != IT_SIZE )
  1534.             {
  1535.                 new_item = new TICKET_ITEM( (MENU_ITEMS) event.code );
  1536.                 new_item->Quantity( 1 );
  1537.  
  1538.                 itemList.Add( new_item );
  1539.  
  1540.                 if ( ticket_list )
  1541.                     ticket_list->Add( new_item );
  1542.  
  1543.                 old_cost = 0;
  1544.                 item_p   = new_item;
  1545.             }
  1546.             else
  1547.             {
  1548.                 item_p->Size( (MENU_ITEMS) event.code );
  1549.  
  1550.                 if ( ticket_list )
  1551.                     ticket_list->IsVisible( item_n, true );
  1552.             }
  1553.             break;
  1554.  
  1555.         }
  1556.  
  1557.         if ( ticket_list && ticket_list->IsVisible( ticket_list->n_selected ) )
  1558.             display->ExplodeRectangle( event.area, ticket_list->p_selected->object_area );
  1559.  
  1560.         break;
  1561.  
  1562.     case EV_GET_SUB_TOTAL:
  1563.         event.target_id     = OI_MENU_MANAGER;      // send the event back to the menu manager
  1564.         event.type          = EV_SUB_TOTAL;         // change the event to a sub total event
  1565.         event.code          = current_sale_type;    // get the current sale type
  1566.         event.data.long_t.a = sub_total;            // get the current sub total
  1567.  
  1568.         AddBGEvent( event );                        // send the event
  1569.  
  1570.         item_p   = NULL;    // defeat the sub-total recalc
  1571.         old_cost = 0;
  1572.  
  1573.         break;
  1574.  
  1575.     case EV_SALE_TYPE_KEY:
  1576.  
  1577.         if ( current_sale_type != (MENU_ITEMS) event.code )
  1578.         {
  1579.             current_sale_type   = (MENU_ITEMS) event.code;  // store the new sale type
  1580.  
  1581.             event.type          = EV_SUB_TOTAL;             // change the event to a sub-total event
  1582.             event.target_id     = OI_MENU_MANAGER;          // send it to the menu manager so it can send to the menu
  1583.             event.data.long_t.a = sub_total;                // copy the latest sub total value
  1584.  
  1585.             AddBGEvent( event );                            // send the event
  1586.         }
  1587.  
  1588.         item_p   = NULL;    // defeat the sub-total recalc
  1589.         old_cost = 0;
  1590.  
  1591.         break;
  1592.     }
  1593.  
  1594.     long new_cost = item_p ? item_p->cost : 0;
  1595.  
  1596.     if ( old_cost != new_cost )
  1597.     {
  1598.         sub_total += ( new_cost - old_cost );
  1599.  
  1600.         event.type          = EV_SUB_TOTAL;
  1601.         event.data.long_t.a = sub_total;
  1602.  
  1603.         if ( ticket_list )
  1604.             ticket_list->owner->Event( event );
  1605.  
  1606.         event.target_id = OI_MENU_MANAGER;
  1607.         AddBGEvent( event );
  1608.     }
  1609.  
  1610.     return ret;
  1611.  
  1612. }
  1613.  
  1614.  
  1615. EVENT_STATUS TICKET_MANAGER::Poll( void )
  1616. {
  1617.     return ES_OK;
  1618. }
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624. // --------------------
  1625. // a ticket item object
  1626.  
  1627. TICKET_ITEM::TICKET_ITEM
  1628. (
  1629.     MENU_ITEMS index
  1630.  
  1631. ) : WINDOW_OBJECT()
  1632. {
  1633.     flags &= ~WOF_CAN_DELETE;
  1634.  
  1635.     selected = false;
  1636.  
  1637.     size       = 0;
  1638.     t_size     = NULL;
  1639.     t_name     = NULL;
  1640.     type       = IT_UNKNOWN;
  1641.     item_index = MI_NONE;
  1642.     size_index = MI_NONE;
  1643.  
  1644.     if ( index > MI_NONE )
  1645.     {
  1646.         if ( (type = menu_list[ index ].type) == IT_SIZE )
  1647.             t_size = menu_list[ size_index = index ].name;
  1648.         else
  1649.             t_name = menu_list[ item_index = index ].name;
  1650.     }
  1651.  
  1652.     color = kernel->GetScheme( SID_ITEM );
  1653.  
  1654. }
  1655.  
  1656.  
  1657. EVENT_STATUS TICKET_ITEM::Event( EVENT & event )
  1658. {
  1659.     EVENT_STATUS ret = ES_OK;
  1660.  
  1661.     switch( event.type )
  1662.     {
  1663.     case EV_SET_COORDS:
  1664.         WINDOW_OBJECT::Event( event );
  1665.         y_quan = ( RectHeight(object_area) - display->GetFontHeight( 0 ) ) / 2;
  1666.         break;
  1667.  
  1668.     case EV_SELECT:
  1669.         selected = true;
  1670.         break;
  1671.  
  1672.     case EV_UNSELECT:
  1673.         selected = false;
  1674.         break;
  1675.  
  1676.     default:
  1677.         ret = WINDOW_OBJECT::Event( event );
  1678.     }
  1679.  
  1680.     return ret;
  1681. }
  1682.  
  1683.  
  1684. void TICKET_ITEM::Draw( void )
  1685. {
  1686.     display->SetDrawColor( selected == true ? color->fill : color->text );
  1687.  
  1688.     if ( t_name )
  1689.         if ( type == IT_FOOD || type == IT_MODIFIER )
  1690.             display->DrawString( object_area.left + x_item, object_area.top + y_quan, t_name, 0 );
  1691.  
  1692.     if ( type != IT_MODIFIER )
  1693.     {
  1694.         if ( t_size )
  1695.             display->DrawString( object_area.left + x_size, object_area.top + y_quan, t_size, 0 );
  1696.  
  1697.         display->DrawString( object_area.right - x_cost, object_area.top + y_quan, t_cost, 0 );
  1698.     }
  1699.  
  1700.     if ( type == IT_MODIFIER && quantity == 0 )
  1701.         display->SetDrawColor( lightred );
  1702.  
  1703.     if ( type != IT_MODIFIER || quantity > 1 || quantity == 0 )
  1704.         display->DrawString( object_area.left + x_quan, object_area.top + y_quan, t_quan, 0 );
  1705.  
  1706. }
  1707.  
  1708.  
  1709. void TICKET_ITEM::Item( MENU_ITEMS index )
  1710. {
  1711.     if ( index > MI_NONE )
  1712.     {
  1713.         if ( index == item_index )
  1714.             Quantity( quantity + 1 );
  1715.  
  1716.         else if ( type == IT_SIZE && menu_list[ index ].type == IT_FOOD )
  1717.         {
  1718.             item_index = index;
  1719.             t_name     = menu_list[ index ].name;
  1720.             type       = IT_FOOD;
  1721.  
  1722.             Size( size_index );
  1723.         }
  1724.     }
  1725.  
  1726. }
  1727.  
  1728.  
  1729. void TICKET_ITEM::Quantity( int q )
  1730. {
  1731.     quantity = q;
  1732.  
  1733.     if ( type == IT_FOOD )
  1734.         cost = quantity * menu_list[ item_index ].cost[ size ];
  1735.     else
  1736.         cost = 0;
  1737.  
  1738.     if ( type == IT_MODIFIER )
  1739.     {
  1740.         if ( quantity > 0 )
  1741.             sprintf( t_quan, "%d X", quantity );
  1742.         else if ( quantity == 0 )
  1743.             strcpy( t_quan, "NO " );
  1744.     }
  1745.     else
  1746.         sprintf( t_quan, "%d", quantity );
  1747.  
  1748.     sprintf( t_cost, "%2.2f", cost / 100.0 );
  1749.  
  1750.     display->SelectFont( 0 );
  1751.  
  1752.  
  1753.     x_quan = 3;
  1754.  
  1755.     if ( type == IT_MODIFIER )
  1756.         x_quan += display->font_width * 3;
  1757.  
  1758.     x_size = x_quan + display->GetStringWidth( t_quan ) + display->font_width;
  1759.  
  1760.     x_item = x_size;
  1761.  
  1762.     if ( type != IT_MODIFIER )
  1763.         x_item += display->GetStringWidth( t_size ) + display->font_width;
  1764.  
  1765.     x_cost = display->GetStringWidth( t_cost ) + 3;
  1766.  
  1767. }
  1768.  
  1769.  
  1770. void TICKET_ITEM::Size( MENU_ITEMS index )
  1771. {
  1772.     size_index = index;
  1773.  
  1774.     size   = 0;
  1775.     t_size = menu_list[ size_index ].name;
  1776.  
  1777.     if ( type == IT_FOOD )
  1778.     {
  1779.         int s = menu_list[ size_index ].size[ 0 ];          // grab the size value
  1780.  
  1781.         for( int n = 0; n < MAX_SIZES; n++ )                // locate it in the food item's table
  1782.             if ( menu_list[ item_index ].size[ n ] == s )
  1783.             {
  1784.                 size   = n;
  1785.                 Quantity( quantity );
  1786.                 return;
  1787.             }
  1788.  
  1789.         t_size = NULL;
  1790.         Quantity( quantity );
  1791.     }
  1792.  
  1793. }
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799. POS_MENU::POS_MENU( void )
  1800. {
  1801.     sub_total_text =
  1802.         order_type_text  =
  1803.         order_cost_text  =
  1804.         tax_text         =
  1805.         grand_total_text = NULL;
  1806.  
  1807.     sub_total_buf[ 0 ] =
  1808.         tax_buf[ 0 ]         =
  1809.         order_cost_buf[ 0 ]  =
  1810.         grand_total_buf[ 0 ] = '\0';
  1811.  
  1812.     tendered_field = NULL;
  1813.  
  1814.     tendered = 0.0;
  1815. }
  1816.  
  1817.  
  1818. EVENT_STATUS POS_MENU::Event( EVENT & event )
  1819. {
  1820.     EVENT_STATUS ret = ES_OK;
  1821.  
  1822.     switch( event.type )
  1823.     {
  1824.     case EV_SUB_TOTAL:
  1825.         if ( sub_total_text )
  1826.         {
  1827.             sprintf( sub_total_buf, "%3.2f", event.data.long_t.a / 100.0 );
  1828.             sub_total_text->ChangeData( sub_total_buf );
  1829.  
  1830.             if ( order_type_text )
  1831.                 order_type_text->ChangeData( menu_list[ event.code ].name );
  1832.  
  1833.             int tc = menu_list[ event.code ].cost[ 0 ];
  1834.  
  1835.             sprintf( order_cost_buf, "%3.2f", tc / 100.0 );
  1836.  
  1837.             if ( order_cost_text )
  1838.                 order_cost_text->ChangeData( order_cost_buf );
  1839.  
  1840.             long tx = event.data.long_t.a * .0725;
  1841.  
  1842.             sprintf( tax_buf, "%3.2f", tx / 100.0 );
  1843.  
  1844.             if ( tax_text )
  1845.                 tax_text->ChangeData( tax_buf );
  1846.  
  1847.             long gt = event.data.long_t.a + tc + tx;
  1848.  
  1849.             sprintf( grand_total_buf, "%3.2f", gt / 100.0 );
  1850.  
  1851.             if ( grand_total_text )
  1852.                 grand_total_text->ChangeData( grand_total_buf );
  1853.  
  1854.         }
  1855.         break;
  1856.  
  1857.     case EV_PRESET_DOLLAR_KEY:
  1858.         if ( event.code == 0 )
  1859.             tendered = 0.0;
  1860.         else
  1861.             tendered += (double) event.code / 100.0;
  1862.  
  1863.         if ( tendered_field )
  1864.             tendered_field->ChangeData();
  1865.  
  1866.         break;
  1867.  
  1868.     case EV_KEYBOARD:
  1869.         if ( tendered_field )
  1870.             ret = tendered_field->Event( event );
  1871.         break;
  1872.  
  1873.     default:
  1874.         ret = WINDOW::Event( event );
  1875.     }
  1876.  
  1877.     return ret;
  1878. }
  1879.  
  1880.  
  1881. // ------------------------
  1882. // the menu selector window
  1883.  
  1884.  
  1885. POS_MENU_WINDOW::POS_MENU_WINDOW( void ) : WINDOW()
  1886. {
  1887.     InitRect( object_area, 250, 0, 640, 68 );
  1888.  
  1889.     color = kernel->GetScheme( SID_POS_MAIN_WIN );
  1890.  
  1891.     SBH = kernel->system_button_height;
  1892.     SBW = kernel->system_button_width;
  1893.  
  1894.     kernel->system_button_height =
  1895.         kernel->system_button_width = 50;
  1896.  
  1897.     gRECT r = { 4, 4, -60, -60 };         *this + new MENU_BUTTON( r, MI_MAIN_MENU );
  1898.     MoveRectX( r, 64 );                  *this + new MENU_BUTTON( r, MI_SIDES_MENU );
  1899.     MoveRectX( r, 64 );                  *this + new MENU_BUTTON( r, MI_CASH_MENU );
  1900.     MoveRectX( r, 64 );                  *this + new COMBO_BUTTON( r, SID_BUTTON, "Exit", 0, WOF_L_BUTTON | WOF_SEND_QUEUE, EV_POS_EXIT );
  1901.     MoveRectX( r, 64 ); r.right = -126;  *this + new CLOCK( r, SID_BUTTON, SID_CLOCK, 0, CSET_FLAGS, COBJ_FLAGS );
  1902.  
  1903.     // tell the menu manager to initialize itself
  1904.  
  1905.     EVENT ev;
  1906.  
  1907.     ev.type      = EV_SELECT_MENU;
  1908.     ev.code      = MI_MAIN_MENU;
  1909.     ev.target_id = OI_MENU_MANAGER;
  1910.     ev.area      = kernel->explode_default;
  1911.  
  1912.     AddBGEvent( ev );
  1913.  
  1914. }
  1915.  
  1916.  
  1917. EVENT_STATUS POS_MENU_WINDOW::Event( EVENT & event )
  1918. {
  1919.     EVENT_STATUS ret = ES_OK;
  1920.  
  1921.     switch( event.type )
  1922.     {
  1923.     case EV_POS_EXIT:
  1924.  
  1925.         // restore the system button size
  1926.  
  1927.         kernel->system_button_height = SBH;
  1928.         kernel->system_button_width  = SBW;
  1929.  
  1930.         // select a non-menu
  1931.  
  1932.         EVENT ev;
  1933.  
  1934.         ev.type = EV_SELECT_MENU;
  1935.         ev.code = PM_NONE;
  1936.         ev.target_id = OI_MENU_MANAGER;
  1937.  
  1938.         AddBGEvent( ev );
  1939.  
  1940.         // close all windows
  1941.  
  1942.         AddUIEvent( EV_CLOSE_ALL );
  1943.  
  1944.         // add the main window
  1945.  
  1946.         ev.type         = EV_ADD_WINDOW;
  1947.         ev.area         = event.area;
  1948.         ev.target_id    = OI_KERNEL;
  1949.         ev.ptr.window_t = new MAIN_WINDOW;
  1950.  
  1951.         AddUIEvent( ev );
  1952.  
  1953.         // tell the TICKET_MANAGER to dump the items
  1954.  
  1955.         ev.type = EV_CLEAR_TICKET;
  1956.         ev.target_id = OI_TICKET_MANAGER;
  1957.         AddBGEvent( ev );
  1958.         break;
  1959.  
  1960.  
  1961.     default:
  1962.         ret = WINDOW::Event( event );
  1963.     }
  1964.  
  1965.     return ret;
  1966.  
  1967. }
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974. // ----------------------
  1975. // a ticket item list box
  1976.  
  1977. TICKET_LIST::TICKET_LIST
  1978. (
  1979.     gRECT r,
  1980.     SCHEME_ID s
  1981.  
  1982. ) : VLIST( r, s, WOF_VLIST | WOF_SEND_OWNER, NO_ITEM_SELECTED, 40 )
  1983. {
  1984.     TICKET_MANAGER::ticket_list = this;
  1985.  
  1986.     scroll_changes = true;
  1987. }
  1988.  
  1989.  
  1990. TICKET_LIST::~TICKET_LIST()
  1991. {
  1992.     TICKET_MANAGER::ticket_list = NULL;
  1993. }
  1994.  
  1995.  
  1996. void TICKET_LIST::Add( WINDOW_OBJECT * element )
  1997. {
  1998.     *this << element;
  1999. }
  2000.  
  2001. void TICKET_LIST::Insert( WINDOW_OBJECT * element )
  2002. {
  2003.     *this <= element;
  2004. }
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010. // --------------------------------------------------------
  2011. // main POS window with ticket list, exit button, and clock
  2012.  
  2013. POS_TICKET_WINDOW::POS_TICKET_WINDOW( void )
  2014. {
  2015.     // set the size and color scheme
  2016.  
  2017.     InitRect( object_area, 0, 0, 250, 480 );
  2018.     color = kernel->GetScheme( SID_POS_TICKET_WIN );
  2019.  
  2020.  
  2021.     // add a ticket item viewer
  2022.  
  2023.     gRECT r;
  2024.  
  2025.     InitRect( r, 5, 5, -240, -380 );
  2026.     *this + ( ticket_list = new TICKET_LIST( r, SID_VLIST ) );
  2027.  
  2028.     *ticket_list + new SCROLL_BAR( SID_SCROLL, SID_BUTTON, 0, 0, 0, SB_V_EDGE, WOF_SCROLL_BAR );
  2029.  
  2030.  
  2031.     // add a ticket sub-total display
  2032.  
  2033.     strcpy( sub_total_buf, "0.00" );
  2034.  
  2035.     int x1 = 245 - ( kernel->system_button_width + 3 );
  2036.     display->SelectFont( 0 );
  2037.     int x2 = x1 - ( 8 * display->font_width );
  2038.  
  2039.     *this + new LABEL( x2, 395, SID_TEXT, "Sub-total:", 0, 0, WOF_TEXT_RJ )
  2040.           + ( sub_total_text = new LABEL( x1, 395, SID_TEXT, sub_total_buf, 0, 0, WOF_TEXT_RJ ) );
  2041.  
  2042.  
  2043.     // add some control buttons
  2044.  
  2045.     InitRect( r, 5, 415, -60, -60 );
  2046.     *this + new COMBO_BUTTON( r, SID_BUTTON, "More", 0, ico_plus, WOF_P_BUTTON | WOF_SEND_QUEUE, EV_EDIT_ITEM, C_MORE );
  2047.  
  2048.     MoveRectX( r, 60 );
  2049.     *this + new COMBO_BUTTON( r, SID_BUTTON, "Less", 0, ico_minus, WOF_P_BUTTON | WOF_SEND_QUEUE, EV_EDIT_ITEM, C_LESS );
  2050.  
  2051.     MoveRectX( r, 60 );
  2052.     *this + new COMBO_BUTTON( r, SID_BUTTON, "No", 0, ico_no, WOF_P_BUTTON | WOF_SEND_QUEUE, EV_EDIT_ITEM, C_NO );
  2053.  
  2054.     MoveRectX( r, 60 );
  2055.     *this + new COMBO_BUTTON( r, SID_BUTTON, "Cancel", 0, ico_trash, WOF_P_BUTTON | WOF_SEND_QUEUE, EV_EDIT_ITEM, C_TRASH );
  2056.  
  2057. }
  2058.  
  2059.  
  2060. EVENT_STATUS POS_TICKET_WINDOW::Event( EVENT & event )
  2061. {
  2062.     EVENT_STATUS ret = ES_OK;
  2063.  
  2064.     switch( event.type )
  2065.     {
  2066.     case EV_KEYBOARD:
  2067.         event.target_id = OI_MENU_MANAGER;
  2068.         AddUIEvent( event );
  2069.         break;
  2070.  
  2071.     case EV_VLIST_SELECT:
  2072.         event.target_id = OI_TICKET_MANAGER;
  2073.         AddBGEvent( event );
  2074.         break;
  2075.  
  2076.     case EV_EDIT_ITEM:
  2077.         if ( event.data.mouse_t.button > M_NO_BUTTONS )
  2078.         {
  2079.             event.target_id = OI_TICKET_MANAGER;
  2080.             AddBGEvent( event );
  2081.         }
  2082.         break;
  2083.  
  2084.     case EV_SUB_TOTAL:
  2085.         sprintf( sub_total_buf, "%3.2f", event.data.long_t.a / 100.0 );
  2086.         sub_total_text->ChangeData( sub_total_buf );
  2087.         break;
  2088.  
  2089.     default:
  2090.         ret = WINDOW::Event( event );
  2091.     }
  2092.  
  2093.     return ret;
  2094.  
  2095. }
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103. // ------------------
  2104. // a menu item button
  2105.  
  2106. MENU_BUTTON::MENU_BUTTON
  2107. (
  2108.     gRECT &     r,
  2109.     MENU_ITEMS index
  2110.  
  2111. ) : COMBO_BUTTON( r, menu_list[ index ].scheme_id,
  2112.                      menu_list[ index ].menu,
  2113.                      menu_list[ index ].font,
  2114.                      menu_list[ index ].icon,
  2115.                      WOF_P_BUTTON )
  2116. {
  2117.     item_index = index;
  2118. }
  2119.  
  2120.  
  2121.  
  2122. void MENU_BUTTON::GetIconSize( int * x, int * y )
  2123. {
  2124.     if ( menu_list[ item_index ].icon_type == PCX_TYPE )
  2125.         *x = *y = 0;
  2126. //        size_PCX( menu_list[ item_index ].icon, x, y );
  2127.     else
  2128.         COMBO_BUTTON::GetIconSize( x, y );
  2129. }
  2130.  
  2131.  
  2132. void MENU_BUTTON::DrawIcon( void )
  2133. {
  2134.     if ( menu_list[ item_index ].icon_type == PCX_TYPE )
  2135.     {
  2136. //        int error = 0;
  2137. //
  2138. //#if defined USE_BGI
  2139. //        error = draw_PCX( (char *) menu_list[ item_index ].icon, data_area.left + icon_x, data_area.top + icon_y, 0 );
  2140. //#elif definded USE_META
  2141. //        rect m = { data_area.left + icon_x,
  2142. //                   data_area.top  + icon_y,
  2143. //                   data_area.left + icon_x + 75,
  2144. //                   data_area.top  + icon_y + 75 };
  2145. //
  2146. //        error = ReadPCX( (char *) menu_list[ item_index ].icon, NULL, &m );
  2147. //#endif
  2148. //        if ( error )
  2149. //            error = error;
  2150.     }
  2151.     else
  2152.         COMBO_BUTTON::DrawIcon();
  2153. }
  2154.  
  2155. void MENU_BUTTON::Draw( void )
  2156. {
  2157.     COMBO_BUTTON::Draw();
  2158.  
  2159.     gPOINT p[3] = { { data_area.left,    data_area.top },
  2160.                    { data_area.left+15, data_area.top },
  2161.                    { data_area.left,    data_area.top+15 } };
  2162.  
  2163.     display->DrawFilledPolygon( p, 3, kernel->GetScheme( SID_W_BLUE ) );
  2164.  
  2165. }
  2166.  
  2167.  
  2168. void MENU_BUTTON::Selected( boolean status )
  2169. {
  2170.     COMBO_BUTTON::Selected( status );
  2171.  
  2172.     if ( status == true )
  2173.     {
  2174.         EVENT ev;
  2175.  
  2176.         ev.type = EV_UNDEFINED;
  2177.         ev.code = item_index;
  2178.         ev.area = object_area;
  2179.  
  2180.         switch( menu_list[ item_index ].type )
  2181.         {
  2182.         case IT_MENU:
  2183.             ev.type      = EV_SELECT_MENU;
  2184.             ev.target_id = OI_MENU_MANAGER;
  2185.             break;
  2186.  
  2187.         case IT_MODIFIER:
  2188.         case IT_FOOD:
  2189.         case IT_SIZE:
  2190.             ev.type      = EV_SELECT_ITEM;
  2191.             ev.target_id = OI_TICKET_MANAGER;
  2192.             break;
  2193.  
  2194.         case IT_SALE_KEY:
  2195.             ev.type      = EV_SALE_TYPE_KEY;
  2196.             ev.target_id = OI_TICKET_MANAGER;
  2197.             break;
  2198.  
  2199.         case IT_PAY_KEY:
  2200.             ev.type      = EV_SELECT_MENU;
  2201.             ev.code      = MI_MAIN_MENU;
  2202.             ev.target_id = OI_MENU_MANAGER;
  2203.             ev.area      = kernel->explode_default;
  2204.  
  2205.             AddBGEvent( ev );
  2206.  
  2207.             ev.type      = EV_CLEAR_TICKET;
  2208.             ev.target_id = OI_TICKET_MANAGER;
  2209.             break;
  2210.  
  2211.         case IT_NUMBER_KEY:
  2212.             ev.type      = EV_KEYBOARD;
  2213.             ev.target_id = OI_KERNEL;
  2214.             ev.data.key_t.ascii = menu_list[ item_index ].size[ 0 ];
  2215.             break;
  2216.  
  2217.         case IT_DOLLAR_KEY:
  2218.             ev.type      = EV_PRESET_DOLLAR_KEY;
  2219.             ev.target_id = OI_KERNEL;
  2220.             ev.code      = menu_list[ item_index ].size[ 0 ];
  2221.             break;
  2222.         }
  2223.  
  2224.         if ( ev.type != EV_UNDEFINED )
  2225.         {
  2226.             if ( ev.type == EV_SELECT_ITEM )
  2227.                 AddBGEvent( ev );
  2228.             else
  2229.                 AddUIEvent( ev );
  2230.         }
  2231.     }
  2232. }
  2233.  
  2234. // end of file: G_TEST.CPP
  2235.